{extend name="pc/admin/layout"/}
{block name="main"}
   <div class="g-1400 g-container" id="pjax-container">
        
<div class="bg-bai b rx3" id="vue-page">
<form id="form-config">
    <div class="t-v t-t">
        <div class="c-sidebar c-sidebar-h pb5 br">
            <div class="c-sidebar-title t-v hui bb">福利配置</div>
            <ul class="c-nav click-nav">
                <li><a href="{:url('pc/admin',['act'=>'other','s'=>'jfdh'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>积分兑换设置</div>
                </a></li>
				<li class="active"><a href="{:url('pc/admin',['act'=>'other','s'=>'qd'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>每日签到设置</div>
                </a></li>
				<li><a href="{:url('pc/admin',['act'=>'other','s'=>'cj'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>抽奖商品设置</div>
                </a></li>
				<li><a href="{:url('pc/admin',['act'=>'other','s'=>'cjset'])}" class="t-v" data-pjax>
                    <div><i class="icon icon-form"></i></div>
                    <div>抽奖规则设置</div>
                </a></li>
            </ul>
        </div>
<div class="c-content bl">
            <div class="col-6 fl br" style="min-height:420px;">
                <div class="g-title t-v pl4 bb">
                    <div class="col-12 h t-v bold">签到活动规则</div>
                </div>
				<div class="p5 o-h">
					<div class="pt1 pb3 in-text">
						<dt class="bold bb pr2 lan">每日首签用户赠送商品类型</dt>
						<dd><select class="form w h8 bb" name="sqd_give_type">
							<option value="1" {if condition="config('sys_sqd_give_type') eq 1" }selected {/if}>VIP会员</option>
							<option value="2" {if condition="config('sys_sqd_give_type') eq 2" }selected {/if}>挂机配额</option>
							<option value="3" {if condition="config('sys_sqd_give_type') eq 3" }selected {/if}>用户余额</option>
						</select></dd>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="ml4 f3 hui">每日第一位签到的用户赠送商品</dt>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="bold bb pr2 lan">每日首签用户赠送商品面值</dt>
						<dd><input class="form w h8 bb" type="number" name="sqd_shop_num"
                                   value="{:config('sys_sqd_shop_num')}"></dd>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="ml4 f3 hui">根据赠送商品类型,赠送VIP天数或挂机配额或余额的数量</dt>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="bold bb pr2 lan">每日签到前多少人赠送积分</dt>
						<dd><input class="form w h8 bb" name="qd_user_give_jf"
                                   value="{:config('sys_qd_user_give_jf')}"></dd>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="ml4 f3 hui">例如100,20就是前一百人赠送积分20</dt>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="bold bb pr2 lan">每日签到连续天数规则</dt>
						<dd><input class="form w h8 bb" name="qd_day_gz"
                                   value="{:config('sys_qd_day_gz')}"></dd>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="ml4 f3 hui">1:10 代表连续签到1天送10积分,以后都是送10积分,多条规则用,隔开</dt>
					</div>
				</div>
            </div>
            <div class="col-6 fl bl" style="margin-left:-1px;">
                <div class="g-title t-v pl4 bb">
                    <div class="col-12 h t-v bold">每日签到发送说说内容</div>
                </div>
				<div class="p5 o-h">
					<div class="pt3 pb3">
						<div><font class="f4 bold lan">文字内容</font></div>
						<div class="mt2"><textarea type="text" class="form b" name="qd_shuo_con" placeholder="每日签到发送说说内容" rows="3" autocomplete="off">{:config('sys_qd_shuo_con')}</textarea></div>
					</div>
					<div class="pt1 pb3 in-text">
						<dt class="bold bb pr2">图片地址</dt>
						<dd><input type="url" class="form w h8 bb" name="qd_shuo_tu" id="upload" placeholder="点击上传图片"
								   onclick="f.click();"
								   value="{:config('sys_qd_shuo_tu')}"
								   autocomplete="off" readonly="readonly"></dd>
					</div>
					<input type="file" id="f" name="f" onchange="sc(this);" style="display:none"/>
				</div>
            </div>
        </div>
</div>
</form>
<div class="c-pagination o-h t-v">
        <div class="c-sidebar"></div>
        <div class="c-content h11 o-h g-btn t-v bt bl">
            <div class="col-12 h t-v f3 hui pl5 pr5 t-c">
			<button class="btn btn-qing btn-md w22 rx1" @click="saveConfig()">保 存 设 置</button></div>
        </div>
    </div>
</div>

    </div>
   {/block}
   {block name='foot'}
	<script>
        new Vue({
                el: '#vue-page',
                methods: {
                    saveConfig: function () {
                        app.ajax("{:url('admin_ajax/config')}", $("#form-config").serialize(), function (data) {
                            if (data.code === 0) {
                                x.msg(data.message, 2)
                            } else {
                                x.msg(data.message, 2)
                            }
                        })
                    }
                }
            });
			
		function sc() {
			var animateimg = $("#f").val(); //获取上传的图片名 带//
			var imgarr = animateimg.split('\\'); //分割
			var myimg = imgarr[imgarr.length - 1]; //去掉 // 获取图片名
			var houzui = myimg.lastIndexOf('.'); //获取 . 出现的位置
			var ext = myimg.substring(houzui, myimg.length).toUpperCase();  //切割 . 获取文件后缀
			var load = x.loading('上传图片中...');
			var file = $('#f').get(0).files[0]; //获取上传的文件
			var fileSize = file.size;           //获取上传的文件大小
			var maxSize = 1048576 * 5;              //最大1MB
			if (ext != '.PNG' && ext != '.GIF' && ext != '.JPG' && ext != '.JPEG' && ext != '.BMP') {
				parent.x.msg('文件类型错误,请上传图片类型');
				layer.close(load);
				return false;
			} else if (parseInt(fileSize) >= parseInt(maxSize)) {
				parent.x.msg('上传的文件不能超过5MB');
				layer.close(load);
				return false;
			} else {
				var data = new FormData($('#form-config')[0]);
				$.ajax({
					url: "{:url('user_ajax/Gnset',['act'=>'upload'])}",
					type: 'POST',
					data: data,
					dataType: 'json',
					cache: false,
					processData: false,
					contentType: false,
					success: function (data) {
						layer.close(load);
					if (data['isSuccess']) {
						x.msg('上传图片成功，保存设置后生效');
						$("#upload").val(''+data['f']+'');
					} else {
						x.msg('上传图片失败');
					}
					}
				});
			}
		}
    </script>
    {/block}